<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%goods_manager}}".
 *
 * @property integer $id
 * @property integer $goods_id
 * @property string $borrower
 * @property string $created_at
 * @property double $long
 * @property integer $status
 *  @property string $mark
 * @property string $return_time
 * @property string $real_return_time
 *  @property Goods $goods 
 */
class GoodsManager extends \yii\db\ActiveRecord
{
    const STATUS=[
        '0'=>'未归还',
        '1'=>'已归还',
        '2'=>'永久'
    ];
    public $category_id;
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%goods_manager}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['goods_id'], 'integer'],
            [['long'], 'number'],
            [['return_time','created_at','real_return_time'], 'safe'],
            [['borrower', 'mark'], 'string', 'max' => 255],
            [['status'], 'string', 'max' => 2],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'goods_id' => '货物id',
            'borrower' => '借用人',
            'created_at' => '借用时间',
            'long' => 'Long',
            'status' => '状态',
            'mark' => '备注',
            'return_time' => '预期归还时间',
            'real_return_time' => '实际归还时间', 
        ];
    }
    
    /**
     * @return \yii\db\ActiveQuery
     */
    public function getGoods()
    {
        return $this->hasOne(Goods::className(), ['id' => 'goods_id']);
    } 
}
